package E2020;

import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;

public class TCPSocket {
    public static void main(String[] args) {
        Socket client = null;
        try {
            client = new Socket(InetAddress.getLocalHost(),7777);

            InputStream  is = client.getInputStream();
            byte[] buf = new byte[1024];
            int len = 0;
            while ((len=is.read(buf))!=-1){
                System.out.println(new String(buf,0,len));
                is.read(buf);
            }

            is.close();
            client.close();
        } catch (Exception e){
            e.printStackTrace();
        }

    }
}
